from django.db import models

# Create your models here.


class Student(models.Model):
    """学生信息表"""
    name = models.CharField(max_length=32, unique=True)
    alias = models.CharField(max_length=32, blank=True, null=True)
    height = models.PositiveSmallIntegerField("身高cm")
    weight = models.DecimalField("体重kg", max_digits=5, decimal_places=2)
    status = models.SmallIntegerField("状态", choices=((1, "Alive"), (2, 'MIA'), (3, 'Gone')))
    tags = models.ManyToManyField('Tag', verbose_name="人物标签", blank=True)
    target = models.ManyToManyField('Person', verbose_name='目标人物', blank=True)

    def show_id(self):
        return 'ID:%s' % self.id
    show_id.short_description = "调用id"

    class Meta:
        verbose_name = "学生信息"
        verbose_name_plural = "学生信息表"

    def __str__(self):
        return self.name


class Person(models.Model):
    name = models.CharField(max_length=32, verbose_name="姓名")
    gender = models.SmallIntegerField("性别", choices=((1, "Male"), (2, 'Female')))
    age = models.PositiveSmallIntegerField('年龄')
    universe = models.SmallIntegerField("宇宙", choices=((1, "Marvel"), (2, 'DC'), (3, 'WOW')))
    bounty = models.DecimalField("赏金", max_digits=10, decimal_places=2)
    comment = models.CharField(max_length=64)

    class Meta:
        verbose_name = "人物"
        verbose_name_plural = "人物表"

    def __str__(self):
        return self.name


class Tag(models.Model):
    name = models.CharField(max_length=16, verbose_name="标签名称")
    date = models.DateTimeField('创建时间', auto_now_add=True)

    class Meta:
        verbose_name = "标签"
        verbose_name_plural = "标签列表"

    def __str__(self):
        return self.name

